* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
}

#game-container {
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

.screen {
    width: 100%;
    height: 100%;
    padding: 2rem;
    position: absolute;
    top: 0;
    left: 0;
    transition: all 0.3s ease;
}

#rules-screen {
    display: block;  /* 初始显示规则屏幕 */
}

.screen.active {
    display: block;
}

h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#rules-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.rules-text {
    margin-bottom: 2rem;
    line-height: 1.6;
    font-size: 1.2rem;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.rules-text p {
    margin-bottom: 1rem;
}

#direct-start-btn {
    padding: 1rem 3rem;
    font-size: 1.5rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #ffd700, #ffa500);
    color: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
    margin-top: 2rem;
    width: auto;
    min-width: 200px;
}

#direct-start-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

#direct-start-btn:active {
    transform: scale(0.95);
}

/* 添加规则页面的演示动画 */
.rules-demo {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin: 1rem auto;
    max-width: 200px;
}

.demo-card {
    width: 80px;
    height: 80px;
    background: linear-gradient(45deg, #4a90e2, #67b26f);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    color: white;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    animation: demoPulse 2s infinite;
}

.demo-card:nth-child(1) { animation-delay: 0s; }
.demo-card:nth-child(2) { animation-delay: 0.5s; }

@keyframes demoPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
}

.demo-card.matched {
    animation: demoMatch 0.5s ease-out forwards;
}

@keyframes demoMatch {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    #rules-screen {
        padding: 1rem;
    }

    .rules-text {
        font-size: 1rem;
    }

    #direct-start-btn {
        padding: 0.8rem 2rem;
        font-size: 1.2rem;
        min-width: 180px;
    }

    .rules-demo {
        max-width: 160px;
    }

    .demo-card {
        width: 60px;
        height: 60px;
        font-size: 12px;
    }
}

#game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    padding: 1rem;
    height: calc(100% - 100px);
}

.game-card {
    width: 100px;
    height: 100px;
    margin: 2px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 12px;
    color: white;
    text-align: center;
    transition: all 0.15s ease;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.game-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.game-card.selected {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border: 2px solid #ffd700;
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1.05);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1.05);
    }
}

.game-card.matched {
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.15s ease;
    animation: matchEffect 0.3s ease-out;
}

@keyframes matchEffect {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin-bottom: 1rem;
}

#timer {
    font-size: 2rem;
    font-weight: bold;
}

#player-scores {
    display: flex;
    gap: 1rem;
}

.player-score {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 5px;
}

#result-screen {
    text-align: center;
}

.winner-info {
    margin: 2rem 0;
    font-size: 2rem;
}

.congrats {
    color: #ffd700;
    margin: 0 1rem;
}

.trophy {
    font-size: 3rem;
}

#final-scores {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 2rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
}

#qrcode {
    width: 200px;
    height: 200px;
    margin-bottom: 1rem;
}

.qr-tip {
    color: #ffd700;
    font-size: 1.2rem;
    text-align: center;
}

.input-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 400px;
    margin: 2rem auto;
}

#player-name {
    padding: 1rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-align: center;
}

#player-name::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

#start-game-btn, #play-again-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #ffd700, #ffa500);
    color: #000;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#start-game-btn:hover, #play-again-btn:hover {
    transform: scale(1.05);
}

#play-again-btn {
    margin-top: 2rem;
}

@media (max-width: 768px) {
    #game-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }

    #game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.3rem;
        padding: 0.5rem;
    }
    
    .game-card {
        width: 70px;
        height: 70px;
        font-size: 10px;
        margin: 1px;
    }

    h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    .game-header {
        padding: 0.5rem;
    }

    #timer {
        font-size: 1.5rem;
    }

    .player-score {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }

    .input-container {
        padding: 0 1rem;
    }

    #player-name {
        font-size: 1rem;
        padding: 0.8rem;
    }

    #start-game-btn, #play-again-btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }

    .rules-text {
        padding: 1rem;
    }

    .rules-text p {
        font-size: 1rem;
    }

    .winner-info {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    #game-board {
        grid-template-columns: repeat(3, 1fr);
    }

    .game-card {
        width: 60px;
        height: 60px;
        font-size: 9px;
    }

    h1 {
        font-size: 1.5rem;
    }

    #timer {
        font-size: 1.2rem;
    }
}

.qr-section {
    margin: 2rem auto;
    text-align: center;
    max-width: 300px;
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#qrcode {
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

#qrcode img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.qr-tip {
    margin-top: 1rem;
    color: #333;
    font-size: 1rem;
    font-weight: bold;
}

.current-players {
    margin-top: 2rem;
    text-align: center;
}

#players-list {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.player-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    color: white;
}

.final-scores-container {
    margin: 2rem 0;
    text-align: center;
}

#final-scores {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.score-rank {
    font-weight: bold;
    color: #ffd700;
}

.score-name {
    flex-grow: 1;
    text-align: left;
    margin: 0 1rem;
}

.score-value {
    font-weight: bold;
    color: #4CAF50;
}

.start-section {
    margin-top: 1rem;
}

.start-btn {
    padding: 1rem 3rem;
    font-size: 1.5rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #ffd700, #ffa500);
    color: #000;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.start-btn:active {
    transform: scale(0.95);
} 